﻿using System;
using Core.Domain.Lexems;

namespace Core.SyntaxAnalysis.Classes
{
    public class VariableType : DataType // конечный класс, для него будет таблица
    {
        private static int m_typeCounter = 100;
        private readonly int m_typeId;
// ReSharper disable NotAccessedField.Local
        private Lexem m_type;
// ReSharper restore NotAccessedField.Local

        private VariableType(Lexem type)
        {
            m_type = type;
            m_typeId = m_typeCounter;
            m_typeCounter++;
        }

        public override int SizeInMemory()
        {
            throw new NotImplementedException();
        }

        public override int TypeId()
        {
            return m_typeId;
        }

        public static DataType PickType(Lexem lex)
        {
            var v = lex.StrValue.ToUpper();
            if (v == "INTEGER")
            {
                return new Integer();
            }
            if (v == "REAL")
            {
                return new Float();
            }
            if (v == "BOOLEAN")
            {
                return new Boolean();
            }
            return new VariableType(lex);
        }
    }
}